home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
language
/
xlisp_21.zoo
/
xlspeed.dif
< prev
next >
Wrap
Internet Message Format
|
1990-02-28
|
47KB
From sce!mitel!uunet!lll-winken!ames!haven!umd5!jonnyg Tue May 23 15:37:24 EDT 1989
Article: 91 of comp.lang.lisp.x
Path: cognos!sce!mitel!uunet!lll-winken!ames!haven!umd5!jonnyg
From: jonnyg@umd5.umd.edu (Jon Greenblatt)
Newsgroups: comp.lang.lisp.x
Subject: Xlisp2.0 speedups... (Part 1 of 3)
Message-ID: <4912@umd5.umd.edu>
Date: 18 May 89 16:58:56 GMT
Reply-To: jonnyg@umd5.umd.edu (Jon Greenblatt)
Organization: University of Maryland, College Park
Lines: 910
The following are changes I have made to xlisp 2.0 source. Most of these
changes produce considerable speed ups. This distribution is very
rough but maybe someone can wade through it and come of with a cleaned
up version of the speed ups. Note this is a striaght context diff so
more than just the speed ups are included, BEWARE! If you are able to
clean up or enhance these speed ups in any way I would apreciate the
feedback.
JonnyG.
diff -c ../xlisp.org/xlbfun.c ../xlisp/xlbfun.c
*** ../xlisp.org/xlbfun.c Sun May 7 22:25:38 1989
--- ../xlisp/xlbfun.c Wed Apr 5 16:18:23 1989
***************
*** 558,563 ****
--- 558,578 ----
return (val);
}
+ LVAL xcopyarray()
+ {
+ LVAL src, dest;
+ int num;
+ register int i;
+
+ src = xlgavector();
+ dest = xlgavector();
+ xllastarg();
+ num = (getsize(src) < getsize(dest)) ? getsize(src) : getsize(dest);
+ for (i = 0; i < num; i++)
+ setelement(dest,i,getelement(src,i));
+ return(dest);
+ }
+
/* xerror - special form 'error' */
LVAL xerror()
{
diff -c ../xlisp.org/xldbug.c ../xlisp/xldbug.c
*** ../xlisp.org/xldbug.c Sun May 7 22:25:43 1989
--- ../xlisp/xldbug.c Wed Apr 5 16:18:24 1989
***************
*** 14,20 ****
extern char buf[];
/* external routines */
! extern char *malloc();
/* forward declarations */
FORWARD LVAL stacktop();
--- 14,20 ----
extern char buf[];
/* external routines */
! extern char *xlmalloc();
/* forward declarations */
FORWARD LVAL stacktop();
diff -c ../xlisp.org/xldmem.c ../xlisp/xldmem.c
*** ../xlisp.org/xldmem.c Sun May 7 22:25:46 1989
--- ../xlisp/xldmem.c Wed Apr 5 16:18:25 1989
***************
*** 6,13 ****
#include "xlisp.h"
/* node flags */
! #define MARK 1
! #define LEFT 2
/* macro to compute the size of a segment */
#define segsize(n) (sizeof(SEGMENT)+((n)-1)*sizeof(struct node))
--- 6,13 ----
#include "xlisp.h"
/* node flags */
! #define MARK 0x20
! #define LEFT 0x40
/* macro to compute the size of a segment */
#define segsize(n) (sizeof(SEGMENT)+((n)-1)*sizeof(struct node))
***************
*** 21,37 ****
SEGMENT *segs,*lastseg,*fixseg,*charseg;
int anodes,nsegs,gccalls;
long nnodes,nfree,total;
! LVAL fnodes;
/* external procedures */
! extern char *malloc();
! extern char *calloc();
/* forward declarations */
! FORWARD LVAL newnode();
FORWARD unsigned char *stralloc();
FORWARD SEGMENT *newsegment();
/* cons - construct a new cons node */
LVAL cons(x,y)
LVAL x,y;
--- 21,50 ----
SEGMENT *segs,*lastseg,*fixseg,*charseg;
int anodes,nsegs,gccalls;
long nnodes,nfree,total;
! LVAL fnodes = NIL;
/* external procedures */
! extern char *xlmalloc();
! extern char *xlcalloc();
/* forward declarations */
! FORWARD LVAL Newnode();
FORWARD unsigned char *stralloc();
FORWARD SEGMENT *newsegment();
+ LVAL _nnode;
+ FIXTYPE _tfixed;
+ int _tint;
+
+ #define newnode(type) (((_nnode = fnodes) != NIL) ? \
+ ((fnodes = cdr(_nnode)), \
+ nfree--, \
+ (_nnode->n_type = type), \
+ rplacd(_nnode,NIL), \
+ _nnode) \
+ : (_nnode = Newnode(type)))
+
+
/* cons - construct a new cons node */
LVAL cons(x,y)
LVAL x,y;
***************
*** 129,140 ****
}
/* cvfixnum - convert an integer to a fixnum node */
! LVAL cvfixnum(n)
FIXTYPE n;
{
LVAL val;
- if (n >= SFIXMIN && n <= SFIXMAX)
- return (&fixseg->sg_nodes[(int)n-SFIXMIN]);
val = newnode(FIXNUM);
val->n_fixnum = n;
return (val);
--- 142,151 ----
}
/* cvfixnum - convert an integer to a fixnum node */
! LVAL Cvfixnum(n)
FIXTYPE n;
{
LVAL val;
val = newnode(FIXNUM);
val->n_fixnum = n;
return (val);
***************
*** 151,157 ****
}
/* cvchar - convert an integer to a character node */
! LVAL cvchar(n)
int n;
{
if (n >= CHARMIN && n <= CHARMAX)
--- 162,168 ----
}
/* cvchar - convert an integer to a character node */
! LVAL Cvchar(n)
int n;
{
if (n >= CHARMIN && n <= CHARMAX)
***************
*** 180,185 ****
--- 191,225 ----
return (val);
}
+ #ifdef WINDOWS
+ LVAL newwinobj(size)
+ int size;
+ {
+ LVAL val;
+ val = newnode(WINOBJ);
+ if (size > 0) {
+ xlprot1(val);
+ if ((val->n_winobj = xldcalloc(1,size)) == NULL) {
+ findmem();
+ if ((val->n_winobj = xldcalloc(1,size)) == NULL)
+ xlfail("insufficient memory");
+ }
+ xlpop();
+ }
+ else val->n_winobj = NULL;
+ return(val);
+ }
+
+ LVAL cvwinobj(p)
+ char *p;
+ {
+ LVAL val;
+ val = newnode(WINOBJ);
+ val->n_winobj = p;
+ return(val);
+ }
+ #endif
+
/* newclosure - allocate and initialize a new closure */
LVAL newclosure(name,type,env,fenv)
LVAL name,type,env,fenv;
***************
*** 204,212 ****
vect = newnode(VECTOR);
vect->n_vsize = 0;
if (bsize = size * sizeof(LVAL)) {
! if ((vect->n_vdata = (LVAL *)calloc(1,bsize)) == NULL) {
findmem();
! if ((vect->n_vdata = (LVAL *)calloc(1,bsize)) == NULL)
xlfail("insufficient vector space");
}
vect->n_vsize = size;
--- 244,252 ----
vect = newnode(VECTOR);
vect->n_vsize = 0;
if (bsize = size * sizeof(LVAL)) {
! if ((vect->n_vdata = (LVAL *)xldcalloc(1,bsize)) == NULL) {
findmem();
! if ((vect->n_vdata = (LVAL *)xldcalloc(1,bsize)) == NULL)
xlfail("insufficient vector space");
}
vect->n_vsize = size;
***************
*** 217,223 ****
}
/* newnode - allocate a new node */
! LOCAL LVAL newnode(type)
int type;
{
LVAL nnode;
--- 257,263 ----
}
/* newnode - allocate a new node */
! LVAL Newnode(type)
int type;
{
LVAL nnode;
***************
*** 248,256 ****
unsigned char *sptr;
/* allocate memory for the string copy */
! if ((sptr = (unsigned char *)malloc(size)) == NULL) {
gc();
! if ((sptr = (unsigned char *)malloc(size)) == NULL)
xlfail("insufficient string space");
}
total += (long)size;
--- 288,296 ----
unsigned char *sptr;
/* allocate memory for the string copy */
! if ((sptr = (unsigned char *)xldmalloc(size)) == NULL) {
gc();
! if ((sptr = (unsigned char *)xldmalloc(size)) == NULL)
xlfail("insufficient string space");
}
total += (long)size;
***************
*** 330,336 ****
LVAL ptr;
{
register LVAL this,prev,tmp;
! int type,i,n;
/* initialize */
prev = NIL;
--- 370,376 ----
LVAL ptr;
{
register LVAL this,prev,tmp;
! register int i,n;
/* initialize */
prev = NIL;
***************
*** 340,380 ****
for (;;) {
/* descend as far as we can */
! while (!(this->n_flags & MARK))
/* check cons and symbol nodes */
! if ((type = ntype(this)) == CONS) {
! if (tmp = car(this)) {
! this->n_flags |= MARK|LEFT;
! rplaca(this,prev);
! }
! else if (tmp = cdr(this)) {
! this->n_flags |= MARK;
rplacd(this,prev);
! }
! else { /* both sides nil */
! this->n_flags |= MARK;
break;
! }
! prev = this; /* step down the branch */
! this = tmp;
! }
!
! /* mark other node types */
else {
! this->n_flags |= MARK;
! switch (type) {
! case SYMBOL:
! case OBJECT:
! case VECTOR:
! case CLOSURE:
! for (i = 0, n = getsize(this); --n >= 0; ++i)
! if (tmp = getelement(this,i))
! mark(tmp);
! break;
! }
! break;
! }
/* backup to a point where we can continue descending */
for (;;)
--- 380,409 ----
for (;;) {
/* descend as far as we can */
! while (!(this->n_type & MARK))
/* check cons and symbol nodes */
! if ((i = (this->n_type |= MARK) & TY